
<div class="breadcrumb d-flex align-items-center px-3">
    <div class="btn btn-icon me-3 js-back" aria-label="返回" role="button" tabindex="0">
        <i class="iconfont icon-left-arrow"></i>
    </div>
    <h2 class="fs-18"><?= $user->username ?></h2>
</div>

<?php include '_user_cover.php' ?>

<!-- <div class="container p-1">
    <div class="row row-cols-3 gx-1 media-list d-flex align-items-center">
        <div class="col"><img src="/img/5.jpg" alt=""></div>
        <div class="col"><img src="/img/6.jpg" alt=""></div>
        <div class="col"><img src="/img/7.jpg" alt=""></div>
        <div class="col"><img src="/img/8.jpg" alt=""></div>
        <div class="col"><img src="/img/9.jpg" alt=""></div>
    </div>
</div> -->

<ul class="feed-list list-unstyled">
<?php if(!$posts[0]): ?>
    <div class="placeholder fs-28">无</div>
<?php else: ?>
    <?php foreach ($posts[0] as $post): ?>
        <li class="feed-item d-flex js-tap" data-href="/post/show/<?= $post->id ?>" data-pid="<?= $post->id ?>">
            <div class="feed-item-count">
                <spap class="post-num">
                    <i><?= $post->comments ?></i>
                    <span class="list-triangle-border"></span>
                    <span class="list-triangle-body"></span>
                </spap>
            </div>
            <div class="d-flex flex-column w-100">
                <p class="typo-text fs-18"><?= $post->content ?></p>
                <?php if($post->images > 0): ?>
                    <?php if($post->type === 'gif'): ?>
                        <img class="img-fluid feed-item-img rounded align-self-baseline mt-2" data-gifffer="/upload/<?= $post->filename ?>" alt="" loading="lazy" decoding="async">
                    <?php else: ?>
                        <img class="img-fluid feed-item-img rounded align-self-baseline mt-2" src="/upload/<?= $post->filename ?>" alt="" data-zoomable loading="lazy" decoding="async">
                    <?php endif ?>
                <?php endif ?>
                <div class="d-flex align-items-center mt-1">
                    <a class="link-dark fs-15 post-meta" href="/user/profile/<?= $post->user_id ?>"><?= $post->username; ?></a>
                    <a class="link-muted fs-15" href="/post/show/<?= $post->id ?>"><?= nice_time($post->created_at) ?></a>
                </div>
            </div>

        </li>
    <?php endforeach; ?>
<?php endif ?>
</ul>

<?php if($posts[1]->totalRows > $posts[1]->eachPage): ?>
<nav aria-label="Page navigation">
    <ul class="pagination justify-content-center p-3">
        <li class="page-item"><a class="page-link" href="<?= $posts[1]->prevPage;?>"><span aria-hidden="true">&lsaquo;</span></a></li>
<?php foreach($posts[1]->listPage as $k=>$v): ?>
    <?php if($k == $posts[1]->currentPage): ?>
        <li class="page-item"><a class="page-link active" href="<?= $v ?>"><?= $k ?></a></li>
    <?php else: ?>
        <li class="page-item"><a class="page-link" href="<?= $v ?>"><?= $k ?></a></li>
    <?php endif ?>
<?php endforeach ?>
        <li class="page-item"><a class="page-link" href="<?= $posts[1]->nextPage;?>"><span aria-hidden="true">&rsaquo;</span></a></li>
    </ul>
</nav>
<?php endif ?>

<script>
    document.addEventListener("DOMContentLoaded", () => {
        // 当前链接添加 active
        highlightActiveLink("user");
        document.getElementById("my-post").classList.add('active');
    });
</script>
